/*
 * =====================================================================================
 *
 *       Filename:  graph.h
 *
 *    Description:  graph reading module
 *
 *        Version:  1.0
 *        Created:  08/11/2009 02:46:38 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Zhao Zhao
 *        Company:  ndssl
 *
 * =====================================================================================
 */

#pragma once

#include "include.h"
#include <vector>
#include <map>
using namespace std;

typedef string ULI;
typedef int			VertexID;
typedef VertexID*	VList;
typedef float		Edge;
typedef int			VSize;
typedef VList*  GRAPH;
typedef map<ULI, VertexID> VIndex;
typedef map<VertexID, ULI> Index;
class Graph
{
public:
	Graph(void);
	~Graph(void);
public:

	//Read graph
	void ReadGraph(const char* graphFilePath);
	void FreeGraph();
	inline GRAPH* GetGraphData(){return &graph;};
	inline VSize  GetGraphSize(){return graphSize;};
	inline VSize* GetGraphDegList(){return degree;};
	inline Index GetGraphIndex(){return index;};	
private:
	GRAPH	graph;
	VSize	graphSize;			//# of nodes of the graph
	VSize*	degree;				//# of neighboring nodes of current node
	bool	directionOpt;		//If the graph is bidirectional, true. Otherwise, false
	bool	weightOpt;			//If the graph is weighted, true. Otherwise, false
	VIndex vIndex;	//map the IDs in the file to 0, 1, ....., according to the reading order in the file
	Index index;    //map the 0, 1,... to real IDs
};
